<?php
// echo "a";
/*设置session*/
$_GET['session_id'] && session_id($_GET['session_id']);
session_start();

if($_GET['act'] == 'logout'){
	$_SESSION = null;
	echo "logout";
	exit;
}

/*接受外部跳转接口，处理登录业务,返回session_id给请求的系统*/
if($_GET["act"] && $_GET['act'] == 'login'){

	$session_id = session_id();
	$url = $_GET["redirect"]."?a=b&session_id=".$session_id; //登录成功后跳转到指定的url
    header ( 'Location: ' . $url );
    exit;
}

/*接受外部系统通过session_id请求session信息*/
if ($_GET["act"] && $_GET['act'] == 'sso') {
    $ret = ['status' => '200', 'data' => ''];
    $ret['data'] = $_SESSION;
    echo json_encode($ret);
    exit;
}

if($_GET["act"] && $_GET['act'] == 'set'){
	$_SESSION = $_GET;
}	

print_r($_SESSION);
